//
// Created by redcat1 on 03.05.2024.
//

#include "test_vector_.h"
#include "test_dsl.h"
#include "vector_.h"
#include <iostream>

//
TEST(VectorStaticDouble, Construct_Normal)
{
  Vector<double, 10> v(5, 7.5);
  ASSERT_EQ("{7.5, 7.5, 7.5, 7.5, 7.5}", ToString(v));
}

//
TEST(VectorStaticDouble, Construct_Empty)
{
  Vector<double, 10> v(0, 7.5);
  ASSERT_EQ("{}", ToString(v));
}

//
TEST(VectorStaticDouble, Construct_NegativeSize)
{
  ASSERT_THROW(VectorSizeException, (Vector<double, 10>(-5, 7.5)));
}

//
TEST(VectorStaticDouble, Construct_BiggerThanCapacity)
{
  ASSERT_THROW(VectorSizeException, (Vector<double, 10>(12, 7.5)));
}

//
TEST(VectorStaticDouble, AtConst_Normal)
{
  Vector<double, 10> v(5, 7.5);
  ASSERT_NEAR(7.5, v[3], 0.0001);
}

//
TEST(VectorStaticDouble, AtConst_NegativeIndex)
{
  Vector<double, 10> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[-1]);
}

//
TEST(VectorStaticDouble, AtConst_TooBigIndex)
{
  Vector<double, 8> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[12]);
}

//
TEST(VectorStaticDouble, At_Normal)
{
  Vector<double, 8> v(5, 7.5);
  v[3] = 1.5;
  ASSERT_NEAR(1.5, v[3], 0.0001);
}

//
TEST(VectorStaticDouble, At_NegativeIndex)
{
  Vector<double, 10> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[-1] = 1.5);
}

//
TEST(VectorStaticDouble, At_TooBigIndex)
{
  Vector<double, 10> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[8] = 1.5);
}

//
TEST(VectorDynamicDouble, Construct_Normal)
{
  Vector<double> v(5, 7.5);
  ASSERT_EQ("{7.5, 7.5, 7.5, 7.5, 7.5}", ToString(v));
}

//
TEST(VectorDynamicDouble, Construct_Empty)
{
  Vector<double> v(0, 7.5);
  ASSERT_EQ("{}", ToString(v));
}

//
TEST(VectorDynamicDouble, Construct_NegativeSize)
{
  ASSERT_THROW(VectorSizeException, (Vector<double>(-5, 7.5)));
}

//
TEST(VectorDynamicDouble, AtConst_Normal)
{
  Vector<double> v(5, 7.5);
  ASSERT_NEAR(7.5, v[3], 0.0001);
}

//
TEST(VectorDynamicDouble, AtConst_NegativeIndex)
{
  Vector<double> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[-1]);
}

//
TEST(VectorDynamicDouble, AtConst_TooBigIndex)
{
  Vector<double> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[12]);
}

//
TEST(VectorDynamicDouble, At_Normal)
{
  Vector<double> v(5, 7.5);
  v[3] = 1.5;
  ASSERT_NEAR(1.5, v[3], 0.0001);
}

//
TEST(VectorDynamicDouble, At_NegativeIndex)
{
  Vector<double> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[-1] = 1.5);
}

//
TEST(VectorDynamicDouble, At_TooBigIndex)
{
  Vector<double> v(5, 7.5);
  ASSERT_THROW(VectorIndexOutOfRange, v[8] = 1.5);
}

//
void RunVectorDoubleTests()
{
  TEST_RUN(VectorStaticDouble, Construct_Normal);
  TEST_RUN(VectorStaticDouble, Construct_Empty);
  TEST_RUN(VectorStaticDouble, Construct_NegativeSize);
  TEST_RUN(VectorStaticDouble, Construct_BiggerThanCapacity);
  TEST_RUN(VectorStaticDouble, AtConst_Normal);
  TEST_RUN(VectorStaticDouble, AtConst_NegativeIndex);
  TEST_RUN(VectorStaticDouble, AtConst_TooBigIndex);
  TEST_RUN(VectorStaticDouble, At_Normal);
  TEST_RUN(VectorStaticDouble, At_NegativeIndex);
  TEST_RUN(VectorStaticDouble, At_TooBigIndex);

  TEST_RUN(VectorDynamicDouble, Construct_Normal);
  TEST_RUN(VectorDynamicDouble, Construct_Empty);
  TEST_RUN(VectorDynamicDouble, Construct_NegativeSize);
  TEST_RUN(VectorDynamicDouble, AtConst_Normal);
  TEST_RUN(VectorDynamicDouble, AtConst_NegativeIndex);
  TEST_RUN(VectorDynamicDouble, AtConst_TooBigIndex);
  TEST_RUN(VectorDynamicDouble, At_Normal);
  TEST_RUN(VectorDynamicDouble, At_NegativeIndex);
  TEST_RUN(VectorDynamicDouble, At_TooBigIndex);
}

//
void RunVectorTests()
{
  RunVectorDoubleTests();
}
